package com.hg.concurent.demo9;

import cn.hutool.core.thread.ThreadUtil;

/**
 * @Author: skh
 * @Date: 2020/1/3 15:23
 * @Description:
 */
public class ThreadLocalDemo {

    static ThreadLocal<String> threadLocal = new ThreadLocal();

    public static void main(String[] args) {

        threadLocal.set("skh");


        ThreadUtil.newThread(()->{
            threadLocal.set("csn");
            String result = threadLocal.get();
            System.out.println("result1 = " + result);
        },"t1").start();

        ThreadUtil.sleep(1000);
        String result = threadLocal.get();
        System.out.println("result2 = " + result);
    }
}
